package vn.pyco.prez.tapestry.pages;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.Asset2;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Path;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionAttribute;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

import vn.pyco.prez.PrezConstants;
import vn.pyco.prez.PrezConstants.Steps;
import vn.pyco.prez.model.Slide;

/**
 * Start page of application prez.
 */

@Import(library="${prez.scripts}/jquery.console.utils.js")
public class Index {
	@SuppressWarnings("unused")
	@SessionAttribute(PrezConstants.SESSION_SELECTED_FILE)
	@Property
	private File _selectedPrez;
	
	@SessionAttribute(PrezConstants.SESSION_STEP)
	private Steps _currentStep;
	
	@Inject
	private Block _show;
	
	@Inject
	private Block _select;
	
	@Inject
	private Block _process;
	
	@Inject
	private JavaScriptSupport _jsSupport;
	
	@Inject
	@Path("${prez.scripts}/jquery.debug.js")
	private Asset2 _debugLib;
	
	@Inject
	@Symbol(SymbolConstants.PRODUCTION_MODE)
	private boolean _productionMode;
	
	@SetupRender
	public void setupRender(){
		if(_currentStep == null) {
			_currentStep = Steps.SELECT;
		}
		if(!_productionMode) {
			_jsSupport.importJavaScriptLibrary(_debugLib);
		}
	}

    public List<Slide> getSlides() {
    	return new ArrayList<Slide>();
    }
    
    public Block getStep(){
    	switch (_currentStep) {
			case SELECT:
				return _select;
	
			case PROCESS:
				return _process;
	
			case SHOW:
				return _show;
	
			default:
				return _select;
		}
    }
}
